#include<bits/stdc++.h>
using namespace std;
int a[100005],c[100005],n,kk,maxx;
bool s[100005];
int al()
{
    int re=0;
    for(int i=2;i<=n;i++)re+=c[i];
    return re;
}
void dfs(int t,bool b)
{

    if(t!=1)
    {
        for(int i=t-1;i>=1;i--)
        {
            if(s[i]==b){
            if(a[t]==a[i])
            {
                c[t]+=a[t];

                //cout<<1<<endl<<endl;
                break;
            }
            break;
            }

            //cout<<s[i]<<endl;
        }
    }
    if(t==n)
    {
        int ak=al();
        if(ak>maxx)maxx=ak;
        //cout<<ak<<endl<<endl;
        return ;
    }
    s[t+1]=0;
    dfs(t+1,0);
    c[t+1]=0;
    s[t+1]=1;
    dfs(t+1,1);
    c[t+1]=0;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    //cout<<1111;
    cin>>kk;
    for(int k=1;k<=kk;k++)
    {
        cin>>n;
        for(int i =1;i<=n;i++)
        {
            cin>>a[i];
        }
        s[1]=0;
        dfs(1,0);
        c[1]=0;
        s[1]=1;
        dfs(1,1);
        //c[1]=0;
        cout<<maxx<<endl;
        maxx=0;
    }


}
